import React from 'react';
import './RadioButton.css';

const RadioButton = ({ category, onCategoryChange }) => {
  const handleCategoryClick = (newCategory) => {
    console.log("Category changed to:", newCategory);  // Debugging: 输出新类别
    onCategoryChange(newCategory); // 更新父组件中的 category
  };

  return (
    <div className='post-category'>
      <ul className="post-category-list"> 
        <li 
          className={category === 'latest' ? 'active' : ''} 
          onClick={() => handleCategoryClick('latest')}
        >
          最新
        </li>
        <li 
          className={category === 'hotest' ? 'active' : ''} 
          onClick={() => handleCategoryClick('hotest')}
        >
         最热
        </li>
      </ul>
    </div>
  );
};

export default RadioButton;

